import java.io.IOException;
import java.io.Serializable;
//import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.*;

/**
 * This is the doctor's orders, a set of instructions as 
 * given by the doctor for a specific patient.
 * @author Matt Lee
 *
 */

public class DoctorOrders implements Serializable{
	private String doctorName;
	//private AbstractCollection<String> prescription;
	//private AbstractCollection<String> labWork;
	
	private List<Prescription> prescription;

	private List<Labwork> labWork;
	
	private String followUp;
	
	private String additionalInstructions;
	
	private static Logger doctorOrdersLog = 
		Logger.getLogger(DoctorOrders.class.getName());
	
	static{
		ConsoleHandler console = new ConsoleHandler();
		console.setLevel(Level.ALL);
		console.setFormatter(new ThunderDragonHtmlFormatter());
		doctorOrdersLog.addHandler(console);
		doctorOrdersLog.setLevel(Level.ALL);
		
		try {
			FileHandler fh = new FileHandler("DoctorOrdersLog.txt");
			fh.setFormatter(new ThunderDragonHtmlFormatter());
			doctorOrdersLog.addHandler(fh);
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			doctorOrdersLog.severe("Failure: Security exception thrown " +
					"when trying to create a new handler " +
					"in DoctorOrders.java.");
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			doctorOrdersLog.severe("Failure: I/O exception thrown " +
					"when trying to create a new handler " +
					"in DoctorOrders.java.");
			e.printStackTrace();
		}
		
	}
	
	public DoctorOrders(String doctor){
		doctorOrdersLog.entering(this.getClass().getName(),
				"DoctorOrders Constructor 1", doctor);
		doctorName = doctor;
		//prescription = new ArrayList<String>();
		//labWork = new ArrayList<String>();
		prescription = new ArrayList<Prescription>();
		labWork = new ArrayList<Labwork>();
		followUp = "";
		additionalInstructions="";
		doctorOrdersLog.exiting(this.getClass().getName(), "DoctorOrders Contructor 1");
	}
	
	public DoctorOrders(String assignedDoctor, List<Prescription> assignedPrescription, 
			List<Labwork> assignedLabwork){
		doctorOrdersLog.entering(this.getClass().getName(), 
				"DoctorOrders Constructor 2", new Object[] {assignedDoctor,
			assignedPrescription, assignedLabwork});
		
		prescription = new ArrayList<Prescription>();
		labWork = new ArrayList<Labwork>();
		this.doctorName = assignedDoctor;
		this.prescription = assignedPrescription;
		this.labWork = assignedLabwork;
		this.followUp = null;
		this.additionalInstructions = null;
		doctorOrdersLog.exiting(this.getClass().getName(), "DoctorOrders Constructor 2");
	}
	
	public DoctorOrders(String assignedDoctor, 
			ArrayList<Prescription> assignedPrescription, 
			ArrayList<Labwork> assignedLabwork, String assignedFollowUp){
		doctorOrdersLog.entering(this.getClass().getName(), 
				"DoctorOrders Constructor 3", new Object[] { assignedDoctor,
			assignedPrescription, assignedLabwork, assignedFollowUp});

		prescription = new ArrayList<Prescription>();
		labWork = new ArrayList<Labwork>();
		this.doctorName = assignedDoctor;
		this.prescription = assignedPrescription;
		this.labWork = assignedLabwork;
		this.followUp = assignedFollowUp;
		this.additionalInstructions = null;
		doctorOrdersLog.exiting(this.getClass().getName(), "DoctorOrders Constructor 3");
	}
	
	public DoctorOrders(String assignedDoctor, 
			ArrayList<Prescription> assignedPrescription, 
			ArrayList<Labwork> assignedLabwork, String assignedFollowUp, 
			String assignedAdditionalInstructions){
		doctorOrdersLog.entering(this.getClass().getName(),
				"DoctorOrders Constructor 3", new Object[] { assignedDoctor,
			assignedPrescription, assignedLabwork, assignedFollowUp, 
			additionalInstructions});

		prescription = new ArrayList<Prescription>();
		labWork = new ArrayList<Labwork>();
		this.doctorName = assignedDoctor;
		this.prescription = assignedPrescription;
		this.labWork = assignedLabwork;
		this.followUp = assignedFollowUp;
		this.additionalInstructions = assignedAdditionalInstructions;
		doctorOrdersLog.exiting(this.getClass().getName(), "DoctorOrders Constructor 3");
	}

/**
 * Determine the followUp procedure after a visit.
 * @param followUp the String representing the followUp instructions.
 */
	public void setFollowUp(String followUp) {
		this.followUp = followUp;
		doctorOrdersLog.finest("Exiting setFollowUp() in class DoctorOrders.");
	}

/**
 * Give additional instructions besides the usual doctor's orders.
 * @param additionalInstructions
 */
	public void setAdditionalInstructions(String additionalInstructions) {
		this.additionalInstructions = additionalInstructions;
		doctorOrdersLog.finest("Exiting setAdditionalInstructions() in DoctorOrders.");
	}

	public String getDoctorName() {
		doctorOrdersLog.finest("Got Doctor's Name.");
		return doctorName;
	}

	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
		doctorOrdersLog.finest("Exiting setDoctorName() in class DoctorOrders");
	}

	public ArrayList<Prescription> getPrescription() {
		doctorOrdersLog.finest("Got the prescription.");
		return (ArrayList<Prescription>) prescription;
	}
	
	public void setPrescription(ArrayList<Prescription> prescription) {
		this.prescription = prescription;
		doctorOrdersLog.finest("Exiting setPrescription() in class DoctorOrders.");
	}

	public ArrayList<Labwork> getLabWork() {
		doctorOrdersLog.finest("Got the labwork.");
		return (ArrayList<Labwork>) labWork;
	}

	public void setLabWork(ArrayList<Labwork> labWork) {
		this.labWork = labWork;
		doctorOrdersLog.finest("Exiting setLabWork() in class DoctorOrders.");
	}

	public String getFollowUp() {
		doctorOrdersLog.finest("Got the followUp.");
		return followUp;
	}

	public String getAdditionalInstructions() {
		doctorOrdersLog.finest("Got the additional instructions.");
		return additionalInstructions;
	}

	@Override
	public String toString() {
		return "DoctorOrders [doctorName=" + doctorName + ", prescription="
				+ prescription + ", labWork=" + labWork + ", followUp="
				+ followUp + ", additionalInstructions="
				+ additionalInstructions + "]";
	}
	
	
}